﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;
using Domain.MainModule.Entities;
using Domain.MainModule.Repositories;
using Infrastructure.Data.Core;
using Infrastructure.Data.MainModule.UnitOfWork;

namespace Infrastructure.Data.MainModule.Repositories
{
    public class DinnerRepository: Repository<Dinners,int>, IDinnerRepository
    {
        #region Constructor

        /// <summary>
        /// Default constructor for this repository
        /// </summary>
        /// <param name="unitOfWork">IMainModuleUnitOfWork dependency, intented to be resolved with IoC</param>
        public DinnerRepository(IQueryableUnitOfWork unitOfWork) : base(unitOfWork) { }

        #endregion

        public override Dinners Get(int id)
        {
            var context = this.UnitOfWork as MainModuleUnitOfWork;
            if (context != null)
            {
                return context.CreateSet<Dinners>().Find(id);
            }
            return null;
        }
    }
}